#pragma once

#include <rpc_transport.h>
#include <knet.h>

#ifdef create
#undef create
#endif

class MockTrans : public rpc::Transport {
    kchannel_ref_t* channel_ { nullptr };
public:
    MockTrans(kchannel_ref_t* channel);
    virtual ~MockTrans();
    // Send data
    // @param data The data need to send
    // @param size data size in byte
    // @return How many bytes sent, <= 0 means error
    virtual int send(const char* data, int size) override;
    // Copy data from stream but doesn't remove it
    // @param data The data need to copy
    // @param size data size in byte
    // @return How many bytes need to copy, <= 0 means error
    virtual int peek(char* data, int size) override;
    // Receive data
    // Copy data from stream and remove them
    // @param data The data need to move
    // @param size The data size in byte
    // @return How many bytes need to move, <= 0 means error
    virtual int recv(char* data, int size) override;
    // Ignore some bytes in stream
    // @param size The data size in byte need to ignore
    virtual int skip(int size) override;
    // Returns how many bytes in stream
    virtual int size() override;
    // Check whether stream has been closed
    virtual bool isClose() override;
    // Close stream
    virtual void close() override;
};

